package P1500;

import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-09 16:12
 */
public class P1598_垂直柱状图 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] counts = new int[26];
        for(int i=0;i<4;++i){
            String input = scanner.nextLine();
            char[] chars = input.toCharArray();
            for(char c:chars){
                int index = c-'A';
                if(index >= 0 && index < 26){
                    counts[index]++;
                }
            }
        }
        scanner.close();
        int max = 0;
        for(int count:counts) max = Math.max(max,count);
        if(max !=0) {
            while (max-- > 0) {
                //先对齐第一列
                if (counts[0] > max) System.out.printf("%c", '*');
                else {
                    System.out.printf(" ");
                }
                for (int i = 1; i < 26; ++i) {
                    if (counts[i] > max) {
                        System.out.printf(" %c", '*');
                    } else {
                        System.out.printf("  ");
                    }
                }
                System.out.println();//换行
            }
        }
        System.out.printf("A");
        for(int i=1;i<26;++i){
            char now = (char)('A'+i);
            System.out.printf(" %c",now);
        }
    }
}
